/*
Copyleft 2006 by T.S.Yo
*/


package exp.util;
import ec.*;
import ec.util.*;

/* 
 * ExpConfig.java
 * 
 * Created: 2006.12.06
 * By: T.S.Yo
 */

/**
 * MyExpParam provide a method to read in parameters for:
 *   - selecting test points : STPflag
 *   - scoring               : SCOflag
 * for experiments.
 *
 * @author T.S.Yo
 * @version 1.0 
 */

public class MyExpParam extends Problem
{
//----------------------------------------------------------------------
/* Parameters for Experiments*/
    /** Select test points for evaluation. Options including: 
        1) Fixed random sampling
        2) New random sampling
        3) All test points
        4) Coevolution 
    */
    public static final int TPOINT_FIXED_RANDOM =1;
    public static final int TPOINT_NEW_RANDOM   =2;
    public static final int TPOINT_ALL          =3;
    public static final int TPOINT_COEVOLVUTION =4;
    /** Define the scoring method. Options including: 
        1) Average score 
        2) Weighted score
        3) MOO score
        4) Similarity
        5) Average Informativeness
        6) Weighted Informativeness
     */    
    public static final int SCORE_AVERAGE    =1;
    public static final int SCORE_WEIGHTED   =2;
    public static final int SCORE_MOO        =3;
    public static final int SCORE_SIMILARITY =4;
    public static final int SCORE_AVE_INFO   =5;
    public static final int SCORE_WEI_INFO   =6;

    public static final String TPOINTS = "SelectTestPoints";
    public static final String SCORING = "Scoring";
    public int STPflag;
    public int SCOflag;
//----------------------------------------------------------------------
/** Setup parameters */
    /* Setup parameters */
    public int readSTPflag(final EvolutionState state, final Parameter base)
    {
        //----------------------------------------------------------------------
        // Parameters for Experiments
        String temp;
        temp = state.parameters.getStringWithDefault(base.push(TPOINTS),null,"");
        if( temp.equalsIgnoreCase( "fixed-random-sampling" ) )
        {
            STPflag=TPOINT_FIXED_RANDOM;
        } else if( temp.equalsIgnoreCase( "new-random-sampling" ) ){
            STPflag=TPOINT_NEW_RANDOM;
        } else if( temp.equalsIgnoreCase( "all" ) ){
            STPflag=TPOINT_ALL;
        } else if( temp.equalsIgnoreCase( "coevolution" ) ){
            STPflag=TPOINT_COEVOLVUTION;
        }else{
            state.output.fatal( "Incorrect value for parameter. Acceptable values: " +
                                "fixed-random-sampling, new-random-sampling, all, " +
                                "coevolution", base.push(TPOINTS) );
        }
        return STPflag;
    }

    public int readSCOflag(final EvolutionState state, final Parameter base)
    //public void setup(final EvolutionState state, final Parameter base)
    {
        //----------------------------------------------------------------------
        // Parameters for Experiments
        String temp = state.parameters.getStringWithDefault(base.push(SCORING),null,"");
        if( temp.equalsIgnoreCase( "average-score" ) )
        {
            SCOflag=SCORE_AVERAGE;
        } else if( temp.equalsIgnoreCase( "weighted-score" ) ){
            SCOflag=SCORE_WEIGHTED;
        } else if( temp.equalsIgnoreCase( "moo" ) ){
            SCOflag=SCORE_MOO;
        } else if( temp.equalsIgnoreCase( "distinction" ) ){
            SCOflag=SCORE_SIMILARITY;
        } else if( temp.equalsIgnoreCase( "average-informativeness" ) ){
            SCOflag=SCORE_AVE_INFO;
        } else if( temp.equalsIgnoreCase( "weighted-informativeness" ) ){
            SCOflag=SCORE_WEI_INFO;
        }else{
            state.output.fatal( "Incorrect value for parameter. Acceptable values: " +
                                "average-score, weighted-score, moo, similarity,"   +
                                " average-informativeness, weighted-informativeness", base.push(SCORING) );
        }
        return SCOflag;
    }
}
